#include <iostream>
#include <string.h>

class String
{
public:
  String(const char* s)
  {
    //std::cout << "Constructor " << s << std::endl;
    int len = strlen(s);
    m_data = new char[len];
    strcpy(m_data, s);
    m_data[len] = '\0';
  }
  String& operator=(const char* s)
  {
    //std::cout << "Copy-Assignment " << s << std::endl;
    strcpy(m_data, s);    
    return *this;
  }
  void Print()
  {
    //std::cout << "Print" << std::endl;
    std::cout << m_data << std::endl;
  }
  void Reverse()
  {
    char *last  = m_data;
    char *first = m_data;
    char  temp;
    while (*last != '\0') 
      last++;
    last--;
    while (first < last) {
      temp   = *first;
      *first = *last;
      *last  = temp;
      first++;
      last--;
    }
  }
  void Squeeze(char c)
  {
    char *s  = m_data;
    char *ss = m_data;
    for (; *ss != '\0'; ss++) {
      if (*ss != c) {
        *s = *ss;
        s++;
      }
    }
    *s = '\0';
  }
  
private:
  char *m_data;  
};

int main()
{
  std::cout << "------Construct" << std::endl;
  String s("abcd");
  s.Print();
  std::cout << "------Copy-Assignment" << std::endl;
  s = "abce";
  s.Print();
  std::cout << "------Reverse" << std::endl;
  s.Reverse();
  s.Print();
  std::cout << "------Squeeze" << std::endl;
  s.Squeeze('b');
  s.Print();
}
